<?php
/**
 * @Notes:【】
 * @Date: 2022-07-02 0:03
 */

namespace App\Controller\Admin\Shipping;

use App\Controller\Admin\BaseController;
use App\Service\Shipping\ShiippingTemplatesService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @Notes:【】
 * @Date: 2022-07-02 9:43
 * @ApiController()
 */
class ShippingTemplatesController extends BaseController
{
    /**
     * @Inject()
     * @var ShiippingTemplatesService
     */
    protected $service;


    /**
     * @Notes:【】
     * @Date: 2022-07-02 9:43
     * @PostApi(path="lists")
     */
    public function lists()
    {
        $params = $this->getParams();
        $data = $this->service->page($this->request->post('is_page', true))->lists($params);
        _SUCCESS($data);

    }

    /**
     * @Notes:【】
     * @Date: 2022-07-02 9:43
     * @PostApi(path="add")
     * @FormData(key="name")
     * @FormData(key="shipping_templates_region")
     * @FormData(key="type")
     */
    public function add()
    {
        $params = $this->getParams();
        $this->service->add($params);

        _SUCCESS();
    }

    /**
     * @Notes:【】
     * @Date: 2022-07-02 9:43
     * @PostApi(path="edit")
     * @FormData(key="name")
     * @FormData(key="id")
     * @FormData(key="shipping_templates_region")
     * @FormData(key="type")
     */
    public function edit()
    {
        $params = $this->getParams();
        $this->service->edit($params->get('id'), $params->except('id'));
        _SUCCESS();
    }

    /**
     * @Notes:【】
     * @Date: 2022-07-02 13:23
     * @PostApi(path="detail")
     * @FormData(key="id")
     */

    public function detail()
    {
        $params = $this->getParams();
        $detail = $this->service->detail($params);
        _SUCCESS($detail);
    }
}